home *** CD-ROM | disk | FTP | other *** search
- -- AN EXAMPLE DROPLET WITH SETABLE PROPERTIES
-
- property type_list : {"MooV"} -- the list of file types which will be processed
- property example_property_A : "On"
- property example_property_B : "On"
-
- -- THE FOLLOWING ROUTINE APPEARS ONLY WHEN THE DROPLET IS DOUBLE-CLICKED
- on run
- repeat
- display dialog "QT Droplet Template" & return & return & ¬
- "Example property A status: " & example_property_A & return & ¬
- "Example property B status: " & example_property_B buttons {"Set Prefs", "Done"} default button 2
- if the button returned of the result is "Done" then
- exit repeat
- else
- display dialog "Set the status of the example property A to:" buttons {"Off", "On"} default button 2
- set the example_property_A to the button returned of the result
-
- display dialog "Set the status of the example property B to:" buttons {"Off", "On"} default button 2
- set the example_property_B to the button returned of the result
- end if
- end repeat
- end run
-
- -- This droplet processes both files or folders of files dropped onto the applet
- on open these_items
- -- CHECK THE VERSION OF QUICKTIME INSTALLED
- -- this routine uses the gestaltVersion_info() sub-routine
- copy my gestaltVersion_info("qtim", 8) to {QT_version, QT_string}
- if the QT_version is less than "0502" then
- display dialog "This script requires QuickTime 5.0.2 or higher." & ¬
- return & return & "The currently installed version is: " & ¬
- QT_string buttons {"Cancel"} default button 1
- end if
- -- EXAMINE AND PROCESS EACH DRAGGED-ON ITEM
- repeat with i from 1 to the count of these_items
- set this_item to (item i of these_items)
- -- GET THE INFO FOR THIS ITEM
- set the item_info to info for this_item
- if folder of the item_info is true then
- -- IF THE ITEM IS A FOLDER, CALL THE PROCESS FOLDER SUB-ROUTINE
- process_folder(this_item)
- else if (alias of the item_info is false) and ¬
- (the file type of the item_info is in the type_list) then
- -- IF THE ITEM IS NOT AN ALIAS AND ITS FILE TYPE IS IN THE LIST,
- -- THEN PROCESS THE ITEM
- process_item(this_item)
- end if
- end repeat
- end open
-
- -- this sub-routine processes folders
- on process_folder(this_folder)
- -- GET A LIST OF FOLDER ITEMS
- set these_items to list folder this_folder without invisibles
- -- EXAMINE AND PROCESS EACH ITEM IN THE LIST
- repeat with i from 1 to the count of these_items
- set this_item to alias ((this_folder as text) & (item i of these_items))
- set the item_info to info for this_item
- if folder of the item_info is true then
- process_folder(this_item)
- -- this conditional checks for the creator code
- else if (alias of the item_info is false) and ¬
- (the file type of the item_info is in the type_list) then
- process_item(this_item)
- end if
- end repeat
- end process_folder
-
- -- this sub-routine processes files
- on process_item(this_item)
- -- NOTE that the variable this_item is a file reference in alias format
- -- FILE PROCESSING STATEMENTS GOES HERE
- with timeout of 3600 seconds -- one hour per movie time limit
- tell application "QuickTime Player"
- activate
- -- SUPPRESS AUTOPLAY AND AUTOPRESENT PROPERTIES IN ORDER TO WORK WITH THE MOVIE
- my toggle_suppress(true)
- -- STOP AND CLOSE ANY EXISTING MOVIES
- stop every movie
- close every movie saving no
- try
- -- CHECK FOR QUICKTIME PRO
- if QuickTime Pro installed is false then
- set the target_URL to "http://www.apple.com/quicktime/download/"
- display dialog "This script requires QuickTime Pro." & return & return & ¬
- "If this computer is currently connected to the Internet, " & ¬
- "click the “Upgrade” button to visit the QuickTime Website at:" & ¬
- return & return & target_URL buttons {"Upgrade", "Cancel"} default button 2
- ignoring application responses
- tell application "Finder"
- open location target_URL
- end tell
- end ignoring
- error number -128
- end if
- -- OPEN THE ITEM
- open this_item
- tell movie 1
- -- IF THE MOVIE IS NOT EDITABLE, POST AN ALERT
- if saveable is false then
- error "This movie has previously been set so that it cannot be copied, edited, or saved."
- end if
-
- -- MOVIE PROCESSING STATEMENTS GO HERE
-
- end tell
- -- SAVE AND CLOSE THE MOVIE
- save movie 1
- close movie 1 saving no
- -- RESET THE APPLICATION SUPPRESS PROPERTY
- my toggle_suppress(false)
- on error error_msg number error_num
- if the error_num is -128 then
- my toggle_suppress(false)
- error number -128
- else
- try
- beep
- display dialog error_msg buttons {"Cancel", "Continue"} default button 2 with icon 1
- on error
- my toggle_suppress(false)
- error number -128
- end try
- end if
- end try
- my toggle_suppress(false)
- close movie 1 saving no
- end tell
- end timeout
- end process_item
-
- on toggle_suppress(status_flag)
- tell application "QuickTime Player"
- set ignore auto play to the status_flag
- set ignore auto present to the status_flag
- end tell
- end toggle_suppress
-
- -- THIS ROUTINE USES THE GESTALT COMMAND TO GET VERSION INFO
- on gestaltVersion_info(gestalt_code, string_length)
- try
- tell application "Finder" to ¬
- copy my NumToHex((computer gestalt_code), ¬
- string_length) to {a, b, c, d}
- set the numeric_version to {a, b, c, d} as string
- if a is "0" then set a to ""
- set the version_string to (a & b & "." & c & "." & d) as string
- return {numeric_version, version_string}
- on error
- return {"", "unknown"}
- end try
- end gestaltVersion_info
-
- on NumToHex(hexData, stringLength)
- set hexString to {}
- repeat with i from stringLength to 1 by -1
- set hexString to ((hexData mod 16) as string) & hexString
- set hexData to hexData div 16
- end repeat
- return (hexString as string)
- end NumToHex